home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: chang.unx.sas.com!walker
- From: walker@chang.unx.sas.com (Doug Walker)
- Subject: Re: Ceck out this bug. What the *** is SASC/6.56 doing?
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <Do9Fy0.HGp@unx.sas.com>
- Date: Thu, 14 Mar 1996 13:53:59 GMT
- X-Nntp-Posting-Host: chang.unx.sas.com
- References: <1120.6643T91T406@login.eunet.no> <874.6644T381T2315@login.eunet.no> <4i17ga$doo@btmpjg.god.bel.alcatel.be> <885.6646T9T693@login.eunet.no>
- Organization: SAS Institute Inc.
-
- In article <885.6646T9T693@login.eunet.no>,
- Patrick Hanevold <patrick.hanevold@login.eunet.no> wrote:
- >
- >>>Tryed "Stack check" and all that. No difference.
- >>>Anyway, the default stack is 4K isnt it?
- >>>Cant think of anything using that additional 1K.
- >>>Dont want it global. Allocate it myself now.
- >>>
- >>OpenScreenTags() need stack too!! Together with the already used stack
- >>by _main, and the 3252 bytes of main(), you only have about 800 bytes
- >>left for OpenScreenTags(), might be too small. Stackcheck will not
- >>find this, because stackcheck does not know the stack-usage of
- >>OpenScreenTags().
- >
- >OpenScreenTags() doesnt crash. exit(0) does.
- >I guess it maby could mess up so exit(0) would crash.
- >Stach check should be smart enough to fail if there was too litle stack left.
- >I would guess none of the OS calls would need more then 4K since thats the
- >default stack size.
-
- With a stack trash, it is very possible that a stack overrun would not be
- detected until cleanup time.
-
- Stack check fails if there is not enough stack to execute the CURRENT FUNCTION.
- If all functions called by the function in question are also compiled with
- stack checking, you're 100% covered. In practice, your program is going to
- have to make system calls and library calls, neither of which are going to have
- stack checking code compiled in.
-
- Stack EXTENSION, on the other hand, allows for a "fudge factor". If the
- remaining stack size at function entry time is less than the global long
- _STKNEED, a new stack extent is allocated. The default _STKNEED value
- is 400 bytes.
-
- There is no way for the compiler to know how much stack the system calls you
- make are going to use, so it is not reasonable to expect the stack checking
- code to catch this situation. If you think you know, use stack extension and
- statically initialize the global long _STKNEED to the amount the system
- routines are going to need.
-
- Ultimate in speed ==> No stack checking/no stack extension
- Ultimate in safety ==> Stack extension with a large _STKNEED value
- Decent compromise ==> Stack checking
-
- Pick one. In the end, it's up to YOU to make sure your code has enough stack
- to run. Don't assume that just because a tool is available, you get to quit
- thinking.
-
- By the way, you could also set your program's stack requirements by statically
- initializing the global long __stack to a multiple of four bytes indicating how
- much stack you want. The SAS/C startup code will allocate a new stack for you
- if the one you are given is too small. For this program, you could probably
- set it to 8K and have no problems (assuming you've been failing with a 4k stack.)
-
- --
- *****
- *|_o_o|\\ Doug Walker walker@unx.sas.com
- *|. o.| ||
- | o |// Any opinions are mine, not those of SAS Institute, Inc.
- ======
-